﻿<?php

class BlogdetailController extends Controller
{
	public function actionIndex()
	{
			$model =  new CommentForm;
			if(isset($_GET['article']))
			{
				$articleId = $_GET['article'];
				$article = ArticleList::model()->findByPk($articleId);
				Yii::app()->session['article'] = $article;
				$this->render('index',array('article'=>$article,'model'=>$model));
			}


		
	}

	public function actionComment()
	{
		$model = new CommentModel;

		if(Yii::app()->request->isAjaxRequest && isset($_POST['CommentForm']))
		{
			$data = $_POST['CommentForm'];
			$model->attributes = $data;
			$model->create_time = date('Y-m-d H:m:s');
			$model->content = $_POST['content'];
			$model->article_id = Yii::app()->session['article']->article_id;
			if($model->save())
			{
				echo 1;
			}else{
				echo 0;
			}
		}
	}


	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}